<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>组件的定义使用</title>
    <style>
      .v-enter,
      .v-leave-to {
        opacity: 0;
        transform: translateX(200px);
      }
      .v-enter-active,
      .v-leave-active {
        transition: all 0.5s ease-in;
      }

      /*    .v-enter,
      .v-leave-to {
        opacity: 0;
        transform: translateX(800px);
      }

      .v-enter-active,
      .v-leave-active {
        transition: all 5s ease;
      } */
    </style>
  </head>
  <body>
    <template id="HomePage">
      <div>
        <h2>首页标题</h2>
      </div>
    </template>
    <template id="ProductPage">
      <div>
        <h3>产品标题</h3>
      </div>
    </template>
    <div id="app">
      <div>
        <a href="" @click.prevent="flag=true">首页</a>
        <a href="" @click.prevent="flag=false">产品中心</a>

        <transition mode="in-out">
          <Home v-if="flag"></Home>
          <Product v-else="flag"></Product>
        </transition>
      </div>
    </div>
  </body>
  <script src="./js/vue.js"></script>
  <script src="https://cdn.bootcdn.net/ajax/libs/vuex/3.2.0/vuex.min.js"></script>
  <script>
    //定义全局组件
    Vue.component("Home", {
      template: "#HomePage"
    })

    Vue.component("Product", {
      template: "#ProductPage"
    })
    var app = new Vue({
      el: "#app",
      data: {
        flag: true
      }
    })
  </script>
</html>
